package com.chz.SupermarketMS.dao;

import com.chz.SupermarketMS.dto.CommodityInventories;
import com.chz.SupermarketMS.dto.CommoditySD;
import com.chz.SupermarketMS.entities.Inventory;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface InventoryRepository extends CrudRepository<Inventory, Long> {
    @Override
     List<Inventory> findAll();

    @Query(nativeQuery = true,value = "SELECT i.inventory_id as inventoryId, ci.commodity_id as commodityId, i.number " +
            "FROM chz.inventory as i left join chz.commodity_inventory ci on i.inventory_id = ci.inventory_id;"
    )
    List<CommodityInventories> commodityInventories();

    Inventory findByInventoryId(long theId);
}
